<?php
/**
 * 系统设置操作功能
 * @package  quanliadmin/app/action
 */

quanli_require('module/base/system/sysConfig.class.php');

class pa_config {

	public function execute(){


        if (isset($_REQUEST['operFlg']) && is_numeric($_REQUEST['operFlg'])) {

            switch ($_REQUEST['operFlg']) {
                case 1:
                    $this->showConfig();
                    break;
                default:
                    backendError('参数错误');
                    break;
            }

        } else {
            backendError('参数错误');
        }


	}

	private function showConfig () {

        global $G_PGLOB;

        //实例系统配置类
        $sysConfig = new sysConfig( $G_PGLOB->DBCA );

        //得到配置组
        $group_array = $sysConfig->getGroup();
        if (empty($group_array)) {
            backendError('配置信息没有找到');
        }

        if (isset($_REQUEST['group_id']) && is_numeric($_REQUEST['group_id'])) {
            $group_id = $_REQUEST['group_id'];
        } else {
            $group_id = $group_array[0]['config_group_id'];
        }


        //查询配置信息
        $arg_array = array(
            'config_group_id' => $group_id,
            'sortname' => 'config_sort',
            'sortorder' => 'ASC'
        );
        $config_array = $sysConfig->searchConfig( $arg_array );
        if ($config_array) {
            $G_PGLOB->smarty->assignByRef('config_array', $config_array);
        }

        $G_PGLOB->smarty->assignByRef('group_array', $group_array);
        $G_PGLOB->smarty->assign('group_id', $group_id);

        $G_PGLOB->smarty->display('system/config.tpl');

	}

	
}